<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="author" content="zhaozhenguo">
	<title>库存信息查询</title>
	<script language="javascript" src="../script/common.js" type="text/javascript"></script>
	<script language="javascript" type="text/javascript">
		//全局变量
		var org = Common.cOrg();	//当前单位
		var qt ={};				//数据表格对象
		var b=false;	
		//页面加载方法
		function load(){
            Eui.showNavigation(); 
            $("mainform").storeLocation.value = Common.cOrg().id;
         	var mainform = $("mainform");
			Common.initSql(mainform.giftType,"gift_info_add_giftType",{},"0","1","全部");
				
			Common.initSql(mainform.subType,"gift_info_add_subType",{},"0","1","全部");
            createTable();
		}
		//-----------导航页面---------通过商品大类及联商品小类-----------	
		var subType;
		function changes(s){
				if(s){
					Common.initSql($("mainform").subType,"gift_info_add_subTypeId",{subTypeId:s},"0","1","全部");
					subType = s;
				}else{
					Common.initSql(mainform.subType,"gift_info_add_subType",{},"0","1","全部");
				} 
			}		
		//商品小类及联商品大类
		function subchanges(s){
		    if(s){
				DWR.call("giftStorageService.getParentTypeId",s,function(v){
					$("giftType").value=v.id;	
				});
			}else if(!s && subType){
				subType = null;
			}else{
				Common.initSql(mainform.giftType,"gift_info_add_giftType",{},"0","1","全部");
			}  
		}
		function createTable(b){
			var columns = [];
			/*var columns = [
			    {title:"礼品编号",width:"9%"},
				{title:"礼品名称",width:"11%"},
				{title:"商品类型",width:"8%"},
				{title:"单价",width:"6%",render:function(v){return Format.formatMoney(v)}},
				{title:"计量单位",width:"6%"},
				{title:"统采级别",width:"6%"},
				{title:"礼品统采机构",width:"12%"},
				{title:"目前库存总的礼品数",width:"9%"},
				{title:"还可以兑换的礼品数",width:"9%"},
				{title:"总预约的礼品数",width:"8%"}
			]*/
			if(b){
				qt = new QueryTable("loy_gift_store2","mainform","datalist",columns);
			}else{
				qt = new QueryTable("loy_gift_store3","mainform","datalist",columns);
			}				
		}
		function showData(){
			DWR.call("giftStorageService.getJb",$("subType").value,function(v){
		      // createTable(v);
			  b=v;
				qt.showTable();			//qt为全局的QueryTable对象
			});		
		}	
				//选择单位控件
	function setOrg(sorg) {
		$("mainform").orgLevel.value = sorg.orgLevel;
		$("mainform").orgId.value = sorg.id;
	    $("mainform").unifiedBuyLevel.value = sorg.name;
	}	
		
	</script>
</head>
<body onload="load()">
	<!--页面导航-->
	<div class="nav"><div id="nav">&nbsp;</div></div>
		<!--查询条件form-->
		<div id="listview">
			<div class="searchForm">
			<form id="mainform" name="mainform">
			   	<input type="hidden" name="orgId"/>
			    <input type="hidden" name="orgLevel"/>
			    <input type="hidden" name="subTypeId">
			<input type="hidden" name="storeLocation">
				<table cellSpacing=0 cellPadding=3 width="100%" border=0 >
				    <tr>
				       <td><label>礼品编号&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label> <input type="text" name="giftCode" id="giftCode"  maxlength="15"></td>
				       <td><label>礼品名称</label> <input type="text" name="giftName" maxlength=40></td>
		                 <td><label>统采机构</label> <input type="text" name="unifiedBuyLevel" readonly class="readonly">
						 <a class="orga" title="选择所属机构" href="javascript:void(0)" onclick="SystemMgnt.selOrg(setOrg)">&nbsp;&nbsp;</a> 
					</tr>
					<tr>
						<td><label>礼品库存总数量</label> <input type="text" name="total" maxlength=8  onblur="checkV(this,'number' )"></td>
						<td><label>商品大类</label> <select name="giftType" onchange="changes(this.value)"></select></td>
						<td><label>商品子类</label> <select name="subType"  onchange="subchanges(this.value)"></select></td>
						<td><button type="button" onclick="showData()">查 询</button></td>	 
					</tr>
				</table>
			</form>		
			</div>
			<div id="datalist"></div>
		</div>
</body>
</html>